package com.newworld.basketballfire.main.dao;

import com.newworld.basketballfire.main.bean.DuesListParam;
import com.newworld.basketballfire.main.dao.mapper.DuesMapper;
import com.newworld.basketballfire.main.dao.mapper.UserMapper;
import com.newworld.basketballfire.service.model.Dues;
import com.newworld.basketballfire.service.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by George on 2019/3/10.
 * DuesDao
 */
@Component
public class DuesDao {

    @Autowired
    private DuesMapper duesMapper;

    @Autowired
    private UserMapper userMapper;

    @Transactional
    public void addDues(Dues dues, User user) {
        duesMapper.addDues(dues);
        userMapper.updateUserDues(user);
    }

    @Transactional
    public void updateDues(Dues dues, User user) {
        duesMapper.updateDues(dues);
        userMapper.updateUserDues(user);
    }

    @Transactional
    public void deleteDues(Dues dues, User user) {
        duesMapper.deleteDues(dues);
        userMapper.updateUserDues(user);
    }

    public Dues getDues(String id) {
        return duesMapper.getDues(id);
    }

    public List<Dues> getDuesList(DuesListParam duesListParam) {
        return duesMapper.getDuesList(duesListParam);
    }

    public int getDuesListTotalCnt(DuesListParam duesListParam) {
        return duesMapper.getDuesListTotalCnt(duesListParam);
    }

    public List<Dues> getDuesListByIds(List<String> ids) {
        return duesMapper.getDuesListByIds(ids);
    }
}
